import java.util.concurrent.TimeUnit;

/**
 * @author: wh(1835734390 @ qq.com)
 * @date: 2023/3/21 10:12
 * @description:
 * @version:
 */
public class ThreadLocalTest {
    public static ThreadLocal<Long> threadLocal = ThreadLocal.withInitial(() -> Thread.currentThread().getId());

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                System.out.println(threadLocal.get());
            }).start();
        }
        TimeUnit.SECONDS.sleep(5);
    }
}
